package com.ler.yrmall.coupon.controller;

import com.ler.yrmall.coupon.entity.CouponHistoryEntity;
import com.ler.yrmall.coupon.service.CouponHistoryService;
import com.ler.yrmall.basic.Form;
import com.ler.yrmall.basic.Result;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Arrays;


/**
 * @author Leron
 */
@RestController
@RequestMapping("/couponHistory")
public class CouponHistoryController {
    
    @Resource
    private CouponHistoryService couponHistoryService;

    /**
     * 列表
     */
    @RequestMapping("/find")
    public Result<?> find(Form request) {
        return Result.ok(couponHistoryService.find(request));
    }


    /**
     * 信息
     */
    @RequestMapping("/getById/{id}")
    public Result<?> getById(@PathVariable("id") Long id) {
        CouponHistoryEntity couponHistory = couponHistoryService.getById(id);
        return Result.ok(couponHistory);
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public Result<?> delete(@RequestBody Long[] ids) {
        couponHistoryService.removeByIds(Arrays.asList(ids));
        return Result.ok();
    }

}
